/**
 * @description 笔记服务类
 * @author AI Assistant
 * @date 2023-10-27
 */

import { BaseService } from './base'
import { STORAGE_KEYS } from '@/utils/storage'
import { Note } from '@/models/note'

export class NoteService extends BaseService {
  constructor() {
    super(STORAGE_KEYS.NOTES)
  }

  create(data) {
    const note = new Note(data)
    return super.create(note.toJSON())
  }

  // 根据任务ID获取笔记
  getNotesByTaskId(taskId) {
    const notes = this.getAll()
    return notes.filter(note => note.taskId === taskId)
      .sort((a, b) => b.createTime - a.createTime) // 按创建时间降序排序
  }

  // 根据计时记录ID获取笔记
  getNotesByTimerId(timerId) {
    const notes = this.getAll()
    return notes.filter(note => note.timerId === timerId)
      .sort((a, b) => b.createTime - a.createTime) // 按创建时间降序排序
  }
} 